package ACWing.SearchAndGraphTheory.DFS;
//165. 小猫爬山

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2022/12/20 14:42
 */
public class TheCatClimbedTHEMountain {
    static int count=0;
    static int min;
    static int n,m;
    static int[]sum=new int[20];
    static boolean[]b=new boolean[19];
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        m=sc.nextInt();
        int[]arr=new int[n];
        for (int i = 0; i < n; i++) {
            arr[i]=sc.nextInt();
        }
        Arrays.sort(arr);
        min=n;
        dfs(n-1,arr);
        System.out.println(min);
    }
    public static void dfs(int x,int[]arr){
        if(count>=min){
            return;
        }
        if(x<0){
            min =count;
            return;
        }

        for (int i = 0; i < count; i++) {
            if(sum[i]+arr[x]<=m){
                sum[i]=sum[i]+arr[x];
                dfs(x-1,arr);
                sum[i]-=arr[x];
            }
        }
        sum[count]=arr[x];
        count++;
        dfs(x-1,arr);
        count--;
        sum[count]=0;
    }
}
